package io.renren.modules.newBackground.shanghaiCmcc.v2.example;


import io.renren.modules.newBackground.shanghaiCmcc.v2.client.OpenapiHttpCilent;
import io.renren.modules.newBackground.shanghaiCmcc.v2.client.OpenapiHttpsCilent;

public class Example {
	public static void main(String[] args) throws Exception {
		
//http协议的调用
		//创建一个http客户端，参数为appCode,apk
		OpenapiHttpCilent client = new OpenapiHttpCilent("appCode应用编码", "apk主秘钥");
			
		// 使用客户端调用接口，参数为apiCode,transactionId,requestBody
			try {
				// 使用 HTTP方式调用openapi
					String response = client.call("apiCode能力编码", "transactionId流水号","请求报文");
					System.out.println(response);				
			} catch (Exception e) {
				e.printStackTrace();
			}

		try {
			// 使用 HTTP方式调用openapi 授权能力
			String response = client.call("apiCode能力编码", "transactionId流水号","请求报文", "A3A16FD311C1CB823AA471668F460239");
			System.out.println(response);
		} catch (Exception e) {
			e.printStackTrace();
		}

	//以下为https协议的调用
		//创建一个https客户端，参数为appCode,keystore加载路径，key密码
 		OpenapiHttpsCilent httpsClient = new OpenapiHttpsCilent("appCode应用编码", "D:/primetonProduct/openapi/sdkkey", "000000");
		
		 //使用客户端调用接口，参数为apiCode,transactionId,requestBody
 		try {
			// 使用 HTTPS方式调用openapi
			String response = httpsClient.callHttps("apiCode能力编码", "transactionId", "request");
			System.out.println(response);
		} catch (Exception e) {
			e.printStackTrace();
		}

		try {
			// 使用 HTTPS方式调用openapi 授权能力
			String response = httpsClient.callHttps("apiCode能力编码", "transactionId", "中文", "A3A16FD311C1CB823AA471668F460239");
			System.out.println(response);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
